Welcome to Perl 6 on the Temporary Notebook (tmpnb) service!

This Notebook Server was launched just for you. It's a temporary way for you to try out a Perl 6 Jupyter notebook.

To run Perl 6 code, type some code and type ctrl-enter or alt-enter. The value of the last expression will be placed into the corresponding Out cell.


In [1]:
"hello, world"


Out[1]:
hello, world

In [2]:
1..5 X~ 'a'..'b'


Out[2]:
(1a 1b 2a 2b 3a 3b 4a 4b 5a 5b)

Type [tab] for autocompletion. Autocompleting a parenthesis will show you unicode set operators.


In [3]:
(2..7) ⊂ (1..10)


Out[3]:
True

SVG::Plot can be used to generate plots.


In [4]:
use SVG;
use SVG::Plot;

my $points = 50;
my @x  = (0..$points).map: { sin(2 * π * $_ / $points) };
my @d1 = (0..$points).map: { 2 * cos(2 * π * $_ / $points) };
my @d2 = (0..$points).map: { cos(2 * π * $_ / $points) };
SVG.serialize: SVG::Plot.new(
    width => 400,
    height => 250,
    :@x,
    values => (@d1, @d2),
    title  => 'sin(x/10), cos(x/10)',
).plot(:xy-lines);


Out[4]:
-0.5 0 0.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 sin(x/10), cos(x/10)